import { Input, Message } from '@arco-design/web-react';
import { useEffect, useState } from 'react';
import DetailItem from '../../../components/detailItem';
import DetailModal from '../../../components/detailModal';
import LoadingMask from '../../../components/loadingMask';
import { apiGetCardFreezeStatus } from '../../../api';

interface Props {
  id: number | string | undefined;
  onCancel: (update?: boolean) => void;
}
export default function GiveCouponDialog({ id, onCancel }: Props) {

  const [details, setDetails] = useState<any>({});


  useEffect(() => {
    getPayCouponList();

  }, []); // eslint-disable-line


  async function getPayCouponList() {
    LoadingMask.show('正在查询中...');
    try {
      let res = await apiGetCardFreezeStatus(id);
      let data = res.data;
      if (data.code === 200) {
        setDetails(data.data);
      } else {

        Message.warning(data.msg ?? '获取流量券列表失败');
      }
    } catch (e: any) {
      Message.error(e.message ?? '获取流量券列表失败');
    }
    LoadingMask.hide();
  }


  return (
    <DetailModal title="查询卡片冻结情况" show className="bw-80" cancelText={'关闭'} onCancel={() => onCancel()} confirmBtnShow={false}>

      <DetailItem
        label="是否冻结"
        labelSpan={5}
        outlet={4}
      >
        {details?.manageStopRestartStatus?.toString() === '0' ? '否' : '是'}
      </DetailItem>
      <DetailItem label="原因" labelSpan={5} outlet={4} >
        <Input.TextArea disabled className="m-input" autoSize value={details?.reason} />
      </DetailItem>
      <DetailItem label="冻结时间" labelSpan={5} outlet={4}>
        <Input className="m-input" disabled value={details?.manageStopRestartStatusTime} />
      </DetailItem>
    </DetailModal>
  );
}
